home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Dec 3, 1999
- // Author: ms
- //
- // Description:
- // This script describes the contents of the context sensitive menus
- // for the subdivision surfaces, originally all in dagMenuProc.mel
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
-
- global proc subdDagMenuProc( int $action, string $item, string $maskList[] )
- {
- string $subdivSelectionPositions[3];
- $subdivSelectionPositions[0] = "W";
- $subdivSelectionPositions[1] = "N";
- $subdivSelectionPositions[2] = "S";
- $subdivSelectionPositions[3] = "E";
-
- int $whichMode = `subdiv -q -proxyMode $item`;
- string $componentsOnThisNode = $item;
-
- if( 1 == $whichMode ) {
- // We're in polygon mode -- update the values of
- // $componentsOnThisNode and $maskList so the marking menu
- // commands below will operate on the poly proxy and not the
- // subd. (The subd components aren't selectable or drawn in
- // proxy mode.)
- //
- // This way, users will use the subd marking menus to turn on
- // "faces," for example, but they'll really be turning on the
- // faces on the poly proxy, not the subd.
- //
- $componentsOnThisNode = subdFindProxyModePolygon( $item );
-
- if( size( $componentsOnThisNode ) > 0 ) {
- string $tmpMask[] = `objectSelectMasks( $componentsOnThisNode )`;
-
- // The poly selection masks aren't in the same order as those
- // for the subs. Remap...
- //
- $maskList[0] = $tmpMask[1]; // vertices
- $maskList[1] = $tmpMask[0]; // edges
- $maskList[2] = $tmpMask[2]; // faces
- $maskList[3] = $tmpMask[3]; // maps/UVs
- }
- // Just protecting ourselves in case we think we're in
- // proxy mode, but we can't find the proxy.
- //
- else {
- $componentsOnThisNode = $item;
- warning( "Cannot find proxy for subdivision surface in proxy mode." );
- }
- }
-
- // create three selection items for the different component types
- //
- string $uiName;
- for ($i = 0; $i < size($maskList); $i++) {
- switch ($maskList[$i]) {
- case "subdivMeshPoint":
- case "vertex":
- $uiName = "Vertex";
- break;
- case "subdivMeshEdge":
- case "edge":
- $uiName = "Edge";
- break;
- case "subdivMeshFace":
- case "facet":
- $uiName = "Face";
- break;
- case "subdivMeshUV":
- case "puv":
- $uiName = "UV";
- break;
- default:
- $uiName = `interToUI $maskList[$i]`;
- break;
- }
- menuItem -l $uiName
- -ecr false
- -c ( "doMenuComponentSelection(\"" +
- $componentsOnThisNode + "\", \"" + $maskList[$i] + "\")")
- -rp $subdivSelectionPositions[$i];
- }
-
- // If there are two subdiv shapes underneath the
- // same transform (for instance, if the user picks a deformed
- // subd, and invokes Deform->Show Intermediate Objects)
- // the getAttr command below of the form
- //
- // getAttr ( $item + ".displayFilter" );
- //
- // will return two values in an int array, instead of a simple
- // int: one value for each of the subdiv shapes under the
- // transform $item.
- //
- // Note that a simliar "setAttr" command
- //
- // setAttr ( $item + ".displayFilter" ) 0 0;
- //
- // would require two numeric values on the command line, for the
- // same reason. Since MEL doesn't allow assigning an int to an
- // int[] (or vice versa) we have to be careful of how we form the
- // commands for these objects.
- //
- // $children[] : all the leaf-level subdiv children of $item
- // $subdShapes : the members of $children that are *not*
- // intermediate objects. For convenience
- // when passing to the setSubdivDisplayLevelAndFilter
- // proc later on, $subdShapes is the string
- // representation of an array.
- // $numSubdShapes: the number of elements in the string "array"
- // $subdShapes.
- //
- string $children[] = `ls -dag -leaf -type subdiv $item`;
- string $subdShapes = "{ ";
- string $firstSubdShape = "";
- int $numSubdShapes = 0, $maybeProxy = 0;
- string $child;
-
- string $mChildren[] = `ls -dag -leaf -type mesh $item`;
- for( $child in $mChildren ) {
- if ( !`getAttr ($child+".io")` &&
- `getAttr ($child+".visibility")`) {
- $maybeProxy = 1;
- }
- }
- // For all leaf-level subdiv shapes under $item
- //
- for( $child in $children ) {
- // Weed out the intermediate objects
- //
- if( !`getAttr ($child+".io")` ) {
- // Keep track of the first one for a command later on.
- //
- if( $numSubdShapes == 0 ) {
- $firstSubdShape = $child;
- }
- // Comma separate members of the string "array"
- //
- else {
- $subdShapes += ", ";
- }
-
- $subdShapes += ( "\"" + $child + "\"" );
- $numSubdShapes++;
- }
- }
- $subdShapes += " } ";
-
- menuItem -l "Finer"
- -annotation "Set Component Display: Finer"
- -echoCommand true
- -c ( "setSubdivDisplayLevelAndFilter " + $subdShapes + "\"+1\" 0" )
- -rp "NW"
- setSubdivComponentDisplayFiner;
-
- menuItem -l "Coarser"
- -annotation "Set Component Display: Coarser"
- -echoCommand true
- -c ( "setSubdivDisplayLevelAndFilter " + $subdShapes + "\"-1\" 0" )
- -rp "SW"
- setSubdivComponentDisplayCoarser;
-
- // The "refine" and "filter" commands below use "setAttr" commands
- // that need one numeric value per valid subdiv shape under the
- // $item transform. Build up a string with desired value repeated
- // an appropriate number of times.
- //
- string $filterString = "";
- for( $i = 0; $i < $numSubdShapes; $i++ ) {
- $filterString += "0 ";
- }
-
- // In the case of multiple subdiv shapes, they could conceivably
- // have different "displayFilter" attribute values. To build up
- // the marking menu commands, we'll just go with the attribute
- // state of the first valid subdiv shape we found.
- //
-
- int $whichMode = `subdiv -q -proxyMode $firstSubdShape`;
- if( 1 == $whichMode ) {
- // We are in polygon mode. Create a menu item to switch back
- // to standard editing mode.
- menuItem -l "Standard"
- -annotation ("Edit subdiv components in the standard mode")
- -echoCommand true
- -c ("subdGivenIntoHierMode " + $item + "")
- -rp "SE"
- setSubdivHierMode;
-
- } else if( 0 == $whichMode ) {
- menuItem -l "Polygon"
- -annotation ("Edit polygon proxy object")
- -echoCommand true
- -c ("subdGivenIntoPolyMode " + $item + " 1 0 0 0")
- -rp "SE"
- setSubdivPolyMode;
- } else if( 2 == $whichMode ) {
- // The Polygon menu item is disabled in this case to
- // indicate that this subdivision surface
- // is not in Polygon Proxy mode, but could be
- // put into Polygon Proxy mode if its construction
- // history was deleted.
-
- string $label;
- string $annotation;
- if ($maybeProxy) {
- // If there is a non-intermediate, visible meshShape
- // thats a sibling of this subdShape, then thats
- // a result of the user binding a skeleton to a
- // a subd in the proxy mode. (which is discouraged,
- // incorrect, but cannot be prevented)
- //
- // If such a mesh is in the history of this subd, then
- // we can be sure that we are in the polygon proxy mode.
- // If so, we should set the label to "Standard"( to which
- // they can switch by deleting history)
- //
- string $inNodes[] = `listHistory -il 2 $firstSubdShape`;
- int $found = 0;
- for ($node in $inNodes) {
- for ($mesh in $mChildren) {
- if ($node == $mesh) {
- $label = "Standard";
- $annotation = "Edit subdiv components in the standard mode";
- $found = 1;
- break;
- }
- }
- if ($found) break;
- }
- if (!$found) {
- $label = "Polygon";
- $annotation = "Edit polygon proxy object";
- }
- } else $label = "Polygon";
-
- menuItem -l $label
- -annotation $annotation
- -en false
- -echoCommand true
- -c ("subdGivenIntoPolyMode " + $item + " 1 0 0 0")
- -rp "SE"
- setSubdivPolyMode;
- }
- }
-